﻿using System.Collections.Generic;

namespace RayDen.Library.Components.SystemComponents
{
    public class TracerFactory
    {
        private static readonly TracerFactory instance = new TracerFactory();

        public static TracerFactory Instance
        {
            get { return instance; }
        }


        protected List<ITracerImplementation> tracers;


        public TracerFactory()
        {
            tracers = new List<ITracerImplementation>();
        }

        public void Populate(ITracerImplementation tracer)
        {
            this.tracers.Add(tracer);
        }

        public void PopulateDefault()
        {
            this.tracers.Add(new Tracers.ConsoleTracer());
        }

        public void Trace(string message)
        {
            foreach (var tracerImplementation in tracers)
            {
                tracerImplementation.Write(message);
            }
        }

        public void WriteLine(string message, params  object[] pars)
        {
            foreach (var tracerImplementation in tracers)
            {
                tracerImplementation.WriteLine(message, pars);
            }
        }
    }
}